import { toRefs, reactive,onMounted } from 'vue';
// import { mapMutations } from 'vuex';
import axios from "axios";
function MusicHook(){
    const state = reactive({
        musics: [],
        toDetail(id,name) {
          this.$router.push(`/detail/${id}`)
          this.$store.commit("changeName",name)
          // this.changeName(name)
        },
        // ...mapMutations("[changeName]")
      });
      onMounted(() => {
        axios.get("http://122.112.161.135:3000/top/playlist").then((res) => {
          state.musics = res.data.playlists;
        });
      });
      const refState = toRefs(state);
      return refState
}
export default MusicHook